package com.ebupt.migu.caller.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.ebupt.migu.caller.entity.MarketSMSCount;
import com.ebupt.migu.caller.entity.ScheduleBean;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.HashMap;
import java.util.List;

/**
 * @author liuyangyang@e-byte.com
 * @description: TODO
 * @date 2024/9/10 15:02
 */
@Mapper
@DS("mysql_mg")
public interface ScheduleMapper {
    List<ScheduleBean> query();

    ScheduleBean qryByStrategyId(@Param("strategyId") String strategyId);

    List<HashMap<String, String>> qryMegaMarketConf();

    // 当strategy_id不存在时插入新记录
    @Insert("INSERT INTO market_sms_count (strategy_id, strategy_name, execute_type, count, create_time) "
        + "VALUES (#{strategy_id}, #{strategy_name}, #{execute_type}, #{count}, #{create_time}) "
        + "ON DUPLICATE KEY UPDATE count = count + #{count}")
    void insertOrUpdateCount(MarketSMSCount marketSmsCount);

    HashMap<String, String> qryMarketInfo(@Param("activityId") String activityId);
}
